{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "65b3db34",
   "metadata": {},
   "outputs": [],
   "source": [
    "from tbe import tvm\n",
    "from tbe import dsl\n",
    "from tbe.dsl.compute import cube_util\n",
    "\n",
    "out_backprop_shape = (1, 1, 7, 7, 16)\n",
    "out_backprop_dtype = \"float16\"\n",
    "filter_frac = (1, 1, 16, 16)\n",
    "filter_dtype = \"float16\"\n",
    "filter_sizes = (16, 16, 1, 1)\n",
    "input_sizes = (1, 16, 7, 7)\n",
    "\n",
    "out_backprop = tvm.placeholder(out_backprop_shape, name=\"out_backprop\", dtype=out_backprop_dtype)\n",
    "filters = tvm.placeholder(filter_frac, name=\"filters\", dtype=filter_dtype)\n",
    "\n",
    "strides = [1, 1]\n",
    "padding = [0, 0, 0, 0]\n",
    "dilations = [1, 1, 1, 1]\n",
    "res_dtype = \"float32\"\n",
    "offset_x = 0\n",
    "offset_w = None\n",
    "kernel_name = \"conv2d_backprop_input_dx_1_1_7_7_16_dy_1_1_7_7_16_dw_16_16_1_1_s_1_1_p_SAME\"\n",
    "\n",
    "group_dict = {\n",
    "    \"groups\": 1,\n",
    "    \"g_extend\": 1,\n",
    "    \"multiple_extend\": 1,\n",
    "    \"dx_c1_extend\": (input_sizes[1] + 16 - 1)// 16,\n",
    "    \"dy_c1_extend\": out_backprop_shape [1],\n",
    "    \"dx_c_ori\": input_sizes[1],\n",
    "    \"dy_c_ori\": filter_sizes[0],\n",
    "    \"filter_batch_ori\": filter_sizes[0],\n",
    "    \"filter_c_ori\": filter_sizes[1],\n",
    "    \"filter_ori_format\": \"NCHW\"\n",
    "}\n",
    "\n",
    "para_dict = {\n",
    "    \"strides\": strides,\n",
    "    \"padding\": padding,\n",
    "    \"dilations\": dilations,\n",
    "    \"res_dtype\": res_dtype,\n",
    "    \"offset_x\": offset_x,\n",
    "    \"offset_w\": offset_w,\n",
    "    \"kernel_name\": kernel_name,\n",
    "    \"group_dict\": group_dict\n",
    "}\n",
    "\n",
    "input_backprop = dsl.conv2d_backprop_input(\n",
    "    filters=filters,\n",
    "    out_backprop=out_backprop,\n",
    "    filter_sizes=filter_sizes,\n",
    "    input_sizes=input_sizes,\n",
    "    para_dict=para_dict\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9c2d31f7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "MindSpore",
   "language": "python",
   "name": "mindspore"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
